﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Tsanie.Utils {
    class Util {
        public static string GetRevision(int startMonth, int startDay, Version ver) {
            string build = ver.Build.ToString("D4");
            string revision = ver.Revision.ToString("D4");
            int result = 0;
            int month = int.Parse(build.Substring(0, 2));
            for (int i = startMonth; i < month; i++) {
                if (i == startMonth) {
                    result += GetDaysOfMonth(startMonth) - startDay;
                } else {
                    result += GetDaysOfMonth(i);
                }
            }
            result += int.Parse(build.Substring(2)) - startDay;
            result /= 10;
            return (result > 0 ? result.ToString() : "") + revision.Substring(0, 3);
        }

        private static int GetDaysOfMonth(int month) {
            switch (month) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    return 31;
                case 2:
                    return 28;
                case 4:
                case 6:
                case 9:
                case 11:
                    return 30;
            }
            return 0;
        }
    }
}
